<?php
/**
 *
 * 韦德教育：韦德教育 个人资料设置逻辑控制器
 * @author 窦子滨 <zibin_5257@163.com>
 * 
 */
class UserconfigAction extends Action{
    function _initialize()  //控制器初始化方法，进行权限的认证
    {
         $System=D('System');
         $System->check_qx_model($_SESSION['qx_id'],5,1);
         unset ($System);
    }
    /**
     * 个人资料设置首页控制器
     */
    public function index(){
        $this->display();
    }


    /**
     * 修改登录密码界面
     */
    public function edit_password(){
        $System=D('System');
        $System->check_qx_model($_SESSION['qx_id'],5,4);
        unset ($System);
        $this->display();
    }


    /**
     * 保存用户修改的密码信息
     */
    public function save_editpwd(){
        $System=D('System');
        $System->check_qx_model($_SESSION['qx_id'],5,4);
        unset ($System);
        $old_pwd=md5(md5($_POST['old_pwd'].'lfy'));
        $new_pwd=md5(md5($_POST['new_pwd'].'lfy'));
        $User=M('User');
        $user_info=$User->where("user_id={$_SESSION['user_id']}")->find();
        if($user_info['user_pwd']!=$old_pwd){
            unset($User);
            $this->ajaxReturn(0);  //原密码不正确
            exit();
        }
        if($User->where("user_id={$_SESSION['user_id']}")->setField('user_pwd',$new_pwd)){
            unset($User);
            $this->ajaxReturn(1);  //新密码修改成功
            exit();
        }else{
            unset($User);
            $this->ajaxReturn(2);  //密码无修改或者系统错误，本次未修改成功！
            exit();
        }
        
    }
}
?>
